﻿
using IM.Easy.Workflow.WorkflowDefine.Demo;
using WorkflowCore.Interface;

namespace IM.Easy.Api.HostedService
{
    public class WorkflowInitService : IHostedService
    {
        private readonly IWorkflowHost _workflowHost;

        public WorkflowInitService(IWorkflowHost workflowHost)
        {
            _workflowHost = workflowHost;
        }

        public Task StartAsync(CancellationToken cancellationToken)
        {
            _workflowHost.RegisterWorkflow<DemoWf>();
            _workflowHost.Start();
            return Task.CompletedTask;
        }

        public Task StopAsync(CancellationToken cancellationToken)
        {
            _workflowHost.Stop();
            return Task.CompletedTask;
        }
    }
}
